<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:perm="http://www.coopservice.it/commons2/permissions"
	xmlns:coop="http://www.coopservice.it/commons2/taglib"
	xmlns:p="http://primefaces.org/ui" template="/WEB-INF/layout/t.xhtml">

	<ui:define name="title">
		<h:outputText value="Lista File di Regole" />
	</ui:define>

	<ui:define name="content">
		<h:form id="regole">
			<h:panelGrid columns="3">

				<h:outputLabel value="Nome:" for="cercaName" />
				<h:outputLabel value="Tipologia:" for="cercaType" />
				<h:outputLabel value="Attiva:" for="cercaAttivo" />

				<h:inputText id="cercaName" style="width: 100%;"
					value="#{ruleController.search.obj.name}" />
				<h:selectOneMenu id="cercaType" style="width: 100%;"
					value="#{ruleController.search.obj.type.id}">
					<f:selectItems value="#{tipologieItems}" />
				</h:selectOneMenu>
				<h:selectOneMenu id="cercaAttivo" style="width: 100%;"
					value="#{ruleController.search.obj.attivo}">
					<f:selectItems value="#{siNoNullItems}" />
				</h:selectOneMenu>

			</h:panelGrid>

			<h:panelGrid columns="2">
				<p:commandButton actionListener="#{ruleController.reloadAjax}"
					value="Cerca" ajax="true" immediate="false" update="ruleTable" />
				<p:commandButton action="#{ruleController.reset}" value="Annulla"
					ajax="false" immediate="true" update="regole" />
			</h:panelGrid>

			<coop:spacer></coop:spacer>
			<coop:spacer></coop:spacer>
			<coop:spacer></coop:spacer>

			<p:dataTable id="ruleTable" var="d" rowIndexVar="index"
				value="#{ruleController.model}" paginator="true"
				paginatorPosition="bottom" rows="10" dynamic="true"
				style="width: 95%;"
				emptyMessage="Non ci sono risultati per la ricerca effettuata.">
				<p:column>
					<f:facet name="header">
						<h:outputText value="num" />
					</f:facet>
					<coop:center>
						<h:outputText value="#{index+1}" />
					</coop:center>
				</p:column>
				<p:column>
					<f:facet name="header">
						<h:panelGrid columns="1">
							<h:outputText value="nome" />
						</h:panelGrid>
					</f:facet>
					<coop:center>
						<h:outputText value="#{d.name}" />
					</coop:center>
				</p:column>
				<p:column>
					<f:facet name="header">
						<h:panelGrid columns="1">
							<h:outputText value="tipologia" />
						</h:panelGrid>
					</f:facet>
					<coop:center>
						<h:outputText value="#{d.type.name}" />
					</coop:center>
				</p:column>
				<p:column>
					<f:facet name="header">
						<h:panelGrid columns="1">
							<h:outputText value="file" />
						</h:panelGrid>
					</f:facet>
					<coop:center>
						<h:outputText value="#{d.filename}" />
					</coop:center>
				</p:column>
				<p:column>
					<f:facet name="header">
						<h:panelGrid columns="1">
							<h:outputText value="attiva" />
						</h:panelGrid>
					</f:facet>
					<coop:center>
						<h:outputText value="SI" rendered="#{d.attivo}" />
						<h:outputText value="NO" rendered="#{not d.attivo}" />
					</coop:center>
				</p:column>
				<p:column>
					<f:facet name="header">
						<h:panelGrid columns="1">
							<h:outputText value="data" />
							<h:outputText value="inserimento" />
						</h:panelGrid>
					</f:facet>
					<coop:center>
						<h:outputText value="#{d.dateCreated}">
							<f:convertDateTime pattern="dd/MM/yyyy HH:mm:ss.SSS"
								timeZone="Europe/Rome" />
						</h:outputText>
					</coop:center>
				</p:column>
				<p:column>
					<f:facet name="header">
						<h:panelGrid columns="1">
							<h:outputText value="data" />
							<h:outputText value="ultima modifica" />
						</h:panelGrid>
					</f:facet>
					<coop:center>
						<h:outputText value="#{d.dateModified}">
							<f:convertDateTime pattern="dd/MM/yyyy HH:mm:ss.SSS"
								timeZone="Europe/Rome" />
						</h:outputText>
					</coop:center>
				</p:column>
				<p:column>
					<f:facet name="header">
						<h:outputText value="visualizza" />
					</f:facet>
					<coop:center>
						<p:commandLink action="#{ruleController.viewElement}"
							immediate="true">
							<div style="font-size: 24px;" title="vedi">
								<i class="icon-info-sign"></i>
							</div>
						</p:commandLink>
					</coop:center>
				</p:column>
				<p:column>
					<f:facet name="header">
						<h:outputText value="modifica" />
					</f:facet>
					<coop:center>
						<p:commandLink action="#{ruleController.modElement}"
							immediate="true">
							<div style="font-size: 24px;" title="modifica">
								<i class="icon-edit"></i>
							</div>
						</p:commandLink>
					</coop:center>
				</p:column>
				<p:column rendered="false">
					<f:facet name="header">
						<h:outputText value="operazioni" />
					</f:facet>
					<coop:center>
						<p:commandButton action="#{ruleController.viewElement}"
							style="width: 1.3em; height: 1.3em;" alt="vedi" title="vedi"
							icon="ui-icon-info" />
						<coop:spacer width="5px" />
						<p:commandButton action="#{ruleController.modElement}"
							style="width: 1.3em; height: 1.3em;" alt="modifica"
							title="modifica" icon="ui-icon-pencil" />
					</coop:center>
				</p:column>
			</p:dataTable>
		</h:form>

		<coop:spacer></coop:spacer>
		<coop:spacer></coop:spacer>
		<coop:spacer></coop:spacer>

		<h:form>
			<p:commandButton action="#{ruleController.addElement}"
				value="Aggiungi" />
		</h:form>

	</ui:define>
</ui:composition>